<?php

class Solution
{
    /**
     * @param Integer[] $costs
     * @param Integer   $coins
     * @return Integer
     */
    function maxIceCream($costs, $coins)
    {
        //排序后
        sort($costs);

        $count = 0;
        //循环获取可用余额
        foreach ($costs as $cost) {
            if ($cost <= $coins) {
                $count++;
                $coins -= $cost;
            }
        }
        return $count;
    }
}
